// require.ensure 是 Webpack 的特殊语法，用来设置 code-split point
const Home = resolve => {
  require.ensure(['./views/index.vue'], () => {
    resolve(require('./views/index.vue'))
  })
}

const List = resolve => {
  require.ensure(['./views/list.vue'], () => {
    resolve(require('./views/list.vue'))
  })
}

const routers = [{
  path: '/',
  name: 'home',
  component: Home
}, {
  path: '/list',
  name: 'list',
  component: List
}, {
  path: '/topic/:id',
  name: 'topic',
  component (resolve) {
    require.ensure(['./views/topic.vue'], () => {
      resolve(require('./views/topic.vue'))
    })
  }
}, {
  path: '/detail/:id',
  name: 'detail',
  component (resolve) {
    require.ensure(['./views/detail.vue'], () => {
      resolve(require('./views/detail.vue'))
    })
  }
}, {
  path: '*',
  component: Home
}]

export default routers
